import Vue from 'vue'
import Vuex from 'vuex'
import { post } from "@/common/axios.js"
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: {},
    loginRandom: 0,
    loginoutRandom: 0,
    loginCode: "",
    statusRandom: 0,
    weChatSelectId: "",
    msg: "",
    selectList: [],
    currentChat: {},
  },
  mutations: {
    isLoginState(state, provider){
      state.user = provider
    },
    userState(state, provider){
      state.user = provider
    }
  },
  actions: {
    // 获取用户基本信息
    getUser(context) {
      post("/front/user/userInfo").then(res=>{
        console.log(res.data)
        window.localStorage.setItem("user", res.data.obj)
        context.commit("userState", res.data.obj)
      })
    },  
  },
})
